﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace ApiLib
{
    public interface IAccountService
    {
        //LoginVM Login(string userName, string pwd);
        LoginVM Login(TokenRequest req);
    }
    public class AccountService : IAccountService
    {
        private LoginVM Login(string userName, string pwd)
        {
            if (userName == "lou") {
                if (pwd == "lou") {
                    return new LoginVM()
                    {
                        UserId = 1,
                        UserName = "lou",
                        RoleId = 1
                    };
                } else {
                    throw new Exception("密码错误");
                }
            } else {
                throw new Exception("用户不存在");
            }
        }

        public LoginVM Login(TokenRequest req)
        {
            return Login(req.UserName, req.Pwd);
        }
    }
}
